/*
 * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */

import { hilog } from '@kit.PerformanceAnalysisKit';
const DOMAIN:number = 0xa1a9
const TAG:string = "ansp"
const FORMAT: string = "%{public}s => %{public}s";

class Logger {
  private domain: number;
  private tag: string;
  private format: string=FORMAT;

  constructor(domain:number=DOMAIN,pre: string=TAG) {
    this.tag = pre
    this.domain = domain
  }

  d(message: Object,flag="Flag") {
    if(!this.isDebugMode()){
      return
    }
    hilog.debug(this.domain, this.tag, this.format, flag,message)
  }

  i(message: Object,flag="Flag") {
    if(!this.isDebugMode()){
      return
    }
    hilog.info(this.domain, this.tag, this.format, flag,message)
  }

  w(message: Object,flag="Flag") {
    if(!this.isDebugMode()){
      return
    }
    hilog.warn(this.domain, this.tag, this.format, flag,message)
  }

  e(message: Object,flag="Flag") {
    if(!this.isDebugMode()){
      return
    }
    hilog.error(this.domain, this.tag, this.format, flag,message)
  }

  isDebugMode():boolean{
    return true
  }
}

const ApLog = new Logger()
function oneLog(domain:number,tag: string=TAG):Logger{
  return new Logger(domain,tag)
}
export {oneLog,ApLog}



